package com.ysd.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ysd.dao.impl.CompanyDaoImpl;
import com.ysd.dao.impl.ProductclassifiCationTableDaoImpl;
import com.ysd.dao.impl.ProductdetailsinfoDaoImpl;
import com.ysd.dao.impl.ShuijituDaoImpl;
import com.ysd.dao.impl.Shuijixinwen;
import com.ysd.dao.impl.lia;
import com.ysd.entity.Company;
import com.ysd.entity.Detailsinfo;
import com.ysd.entity.ProductclassifiCationTable;
import com.ysd.entity.Productdetailsinfo;

public class HomeServlet extends HttpServlet {
	

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//调用实现类
		CompanyDaoImpl cDao = new CompanyDaoImpl();
		Company c = cDao.getCompany();
		request.setAttribute("c", c);
		//产品分类
		ProductclassifiCationTableDaoImpl pDao = new ProductclassifiCationTableDaoImpl();
		List<ProductclassifiCationTable> ist = pDao.gatProductclassifiCationTables();
		request.setAttribute("pc", ist);
		
		//随机图片
		ShuijituDaoImpl sDao = new ShuijituDaoImpl();
		List<Productdetailsinfo> list = sDao.Productdetailsinfo();
		request.setAttribute("p", list);
		//两张图
		lia lDao = new lia();
		List<Detailsinfo> detList = lDao.Detailsinfo();
		request.setAttribute("detList", detList);
		
		//随机新闻
		Shuijixinwen xDao = new Shuijixinwen();
		List<Detailsinfo> xlist = xDao.Detailsinfo();
		request.setAttribute("x", xlist);
		
		request.getRequestDispatcher("index.jsp").forward(request, response);
		
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
